<!DOCTYPE HTML>
<html lang="zh-CN">




<head>
    <meta charset="utf-8">
    <meta name="keywords" content="&#39;DataType&#39;, 深度学习 故障诊断 Java">
    <meta name="description" content="河海大学 | 计算机与信息学院 | 信号与信息处理">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>&#39;DataType&#39; | 世庆的博客</title>
    <link rel="icon" type="image/png" href="/shiqing/favicon.png">

    <link rel="stylesheet" type="text/css" href="/shiqing/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/css/my.css">

    <script src="/shiqing/libs/jquery/jquery.min.js"></script>

    <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
<meta name="generator" content="Hexo 6.3.0"></head>




    <body>
        <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/shiqing/" class="waves-effect waves-light">
                    
                    <img src="/shiqing/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">世庆的博客</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/shiqing/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">世庆的博客</div>
        <div class="logo-desc">
            
            河海大学 | 计算机与信息学院 | 信号与信息处理
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/sqtian-hhu/" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/sqtian-hhu/" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

        



<div class="bg-cover pd-header post-cover" style="background-image: url('/shiqing/medias/featureimages/20.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">&#39;DataType&#39;</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/shiqing/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/shiqing/tags/Java%E5%9F%BA%E7%A1%80/">
                                <span class="chip bg-color">Java基础</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/shiqing/categories/Java/" class="post-category">
                                Java
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-10-26
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/shiqing/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>数组,字符串,集合等等总结</p>
<span id="more"></span>

<p>import java.util.*;</p>
<p>public class 基础结构 {</p>
<pre><code>public static void main(String[] args) &#123;

    arrays();
    System.out.println();

    strings();
    System.out.println();

    collection();
    System.out.println();

    map();
    System.out.println();

    transfer();
    System.out.println();


&#125;

public static void arrays()&#123;
    //数组的初始化
    /**
     * 动态初始化（指定长度）
     * 格式：
     * 数据类型 [] 数组名称 = new 数据类型[数组长度]
     */
    int[] array1 = new int[5];
    array1[0] = 1;
    array1[1] = 2;
    array1[2] = 3;
    array1[3] = 4;
    array1[4] = 5;

    /**
     * 静态初始化（指定内容）
     * 格式：
     * 数据类型 [] 数组名称 = new 数据类型[]&#123;元素一，元素二，元素三，….&#125;
     */

    String[] array2 = new String[]&#123;&quot;a&quot;,&quot;b&quot;,&quot;c&quot;&#125;;

    //省略格式
    String[] array3 = &#123;&quot;a&quot;,&quot;b&quot;,&quot;c&quot;&#125;;


    /**
     * 访问数组：数组名称[索引值]
     * 获取数组长度：arrayA.length
     * 数组一旦创建，程序运行期间，长度不可改变
     * 想返回多个值时，需要用数组
     */

    for (int i = 0; i &lt; array1.length; i++) &#123;
        array1[i] += 1;
        System.out.print(array1[i]+&quot; &quot;);    //2 3 4 5 6
    &#125;
&#125;

public static void strings()&#123;
    /**
     * 字符串内容永不可变
     * 因此，字符串可以共享使用
     * 字符串效果上相当于char[]
     */

    //创建字符串的方法
    String str1 = &quot;hello&quot;; //直接创建

    char[] charArray = &#123;&#39;A&#39;,&#39;B&#39;,&#39;C&#39;&#125;;
    String str2 = new String(charArray); //根据字符数组内容创建

    byte[] byteArray = &#123;97,98,99&#125;;
    String str3 = new String(byteArray); //根据字节数组

    System.out.print(&quot;str1:&quot;+str1+&quot; str2:&quot;+str2+&quot; str3:&quot;+str3);     //str1:hello str2:ABC str3:abc

    /**
     * String中常用方法
     * 长度： str.length()
     *
     * 拼接： str1.concat(str2) //str1不会变化，字符串是常量，返回全新的字符串
     * &quot;&quot;+&quot;&quot;
     *
     * 获取指定索引的字符： charAt()
     * char ch = str.charAt(1);
     *
     * 查找参数字符串，第一次出现的索引，没有则返回-1
     * int index = original.indexOf(“cc”);
     *
     * 截取： [ , )
     * public String substring(int index); //截取指定位置到最后
     * public String substring(int begin,int end);
     *
     * 转换成字符数组：
     * char[] chars = “Hello”.toCharArray(); //变成数组
     *
     * 转换成字节数组：
     * byte[] bytes = “abc”.getBytes()
     *
     * 替换：
     * String lang2 = lang1.replace(charsequence oldstring,charsequence newstring);
     *
     * 分割：
     * String str1 = “aaa,bbb,ccc”;
     * String[] a1 = str1.split(“,”);
     */

    for (int i = 0;i&lt;str1.length();i++)&#123;
        str2 += str1.charAt(i);

    &#125;

    String newstring = str2.replace(&quot;ll&quot;,&quot;LL&quot;);
    System.out.println();
    System.out.print(newstring.substring(2,newstring.length()));     //CheLLo

&#125;

public static void collection()&#123;

    /**
     * Collection接口
     * Collection 常用功能
     * public boolean add(E e); 把给定对象添加到当前集合中
     * public void clear(); 清空集合中所有元素
     * public boolean remove(E e); 把给定对象在当前集合中删除
     * public boolean contains(E e); 判断当前集合中是否包含给定对象
     * public boolean isEmpty(); 判断当前集合是否为空
     * public int size(); 返回集合中元素的个数
     * public Object[] toArray(); 把集合中的元素存储到数组中
     *
     *
     * Collection接口
     *              -&gt;1. List接口   -&gt; Vecter集合
     *                              -&gt; ArrayList集合
     *                              -&gt; LinkedList集合
     *              -&gt;2. Set接口    -&gt;TreeSet集合
     *                              -&gt;HashSet集合     -&gt;LinkedHashSet集合
     *
     */


    /**
     * List接口
     * 继承了Collection接口
     * 特点：
     * 1. 有序的集合，存储元素和取出元素的顺序是一致的(存储123，取出123)
     * 2. 有索引，包含了一些带索引的方法
     * 3. 允许存储重复的元素
     * List接口中带索引的方法(特有)
     * add(int index,E element): 将指定的元素添加到该集合指定位置上
     * get(int index): 返回集合中指定位置的元素
     * remove(int index): 移除列表中指定位置的元素，返回的是被移除的元素
     * set(int index,E element): 用指定元素替换集合中指定位置的元素，返回更新前的元素
     */


    /**
     * ArrayList集合：底层使用的是数组，因此增删慢，查找快
     *
     * &lt;&gt;代表泛型 装什么类型，只能放引用类型,不能放基本类型
     * 想放基本类型，必须使用“包装类”
     * 数组长度不可以改变
     * 但ArrayList可以改变
     * ArrayList直接打印得到的不是地址值，而是内容
     * 增加：list.add();
     * 获取：list.get(i);
     * 删除：list.remove(i);//返回删除的值
     * 尺寸：int size = list.size();
     */

    List&lt;Double&gt; doubles = new ArrayList&lt;&gt;();
    doubles.add(100d);
    doubles.add(99.99d);
    for (int i = 0; i &lt; doubles.size(); i++) &#123;
        System.out.print(doubles.get(i)+&quot; &quot;);   //100.0 99.99
    &#125;




    /**
     * LinkedList集合：List接口的链表实现，查询慢，增删快
     * 包含大量首尾元素方法
     * 使用特有方法时，不能使用多态
     * addFirst(E e): 将指定元素插入此列表开头
     * addLast(E e): 将指定元素添加到此列表结尾
     * push(E e): 将元素推入此列表表示的堆栈
     * pop(): 从堆栈弹出一个元素
     * getFirst(): 返回列表第一个元素
     * getLast():返回此列表最后一个元素
     * removeFirst(): 移除并返回此列表第一个元素
     * removeLast(): 一处并返回此列表最后一个元素
     * isEmpty(): 从此列表所表示的堆栈处弹出一个元素
     */
    System.out.println();
    System.out.print(&quot;LinkedList&quot;);
    LinkedList&lt;Integer&gt; linkedList = new LinkedList&lt;&gt;();
    for (int i = 0; i&lt;4;i++)&#123;
        linkedList.addFirst(i*i);
        linkedList.addLast(i);
    &#125;

    for (Integer integer : linkedList) &#123;
        System.out.print(integer);       //LinkedList94100123
    &#125;


    /**
     * Set接口:
     * 继承了Collection接口
     * 不允许存储重复的元素
     * 没有带索引的方法，也不能使用普通的for循环遍历,要使用迭代器Iterator遍历或者增强for循环
     */

    /**
     * HashSet是一个无序的集合，存储元素与取出元素有可能不一致
     * 底层是一个哈希表结构(散列表,查询速度非常快)
     * 哈希表：采用数组+链表+红黑树实现，当链表长度超过阈值(8)时，将链表转换为红黑树，大大减少查找时间
     * 存储数据到集合中，先计算元素的哈希值
     * 数组结构把元素进行了分组，(相同哈希值的元素是一组)链表/红黑树结构把相同哈希值的元素连接到了一起
     */
    System.out.println();
    System.out.print(&quot;HashSet:&quot;);
    HashSet hashSet = new HashSet&lt;&gt;();
    for (int i = 0;i&lt;5;i++)&#123;
        hashSet.add(i);
    &#125;
    hashSet.add(&quot;h&quot;);
    hashSet.add(&quot;a&quot;);
    hashSet.add(&quot;s&quot;);
    hashSet.add(&quot;h&quot;);
    
    //Set集合遍历第一种方式:使用迭代器遍历
    Iterator it = hashSet.iterator();
    while (it.hasNext())&#123;
        System.out.print(it.next()+ &quot; &quot;);   //HashSet:0 1 a 2 3 s 4 h   无序
    &#125;


    /**
     * LinkedHashSet集合: 继承了HashSet
     * 底层是一个哈希表+链表，多了一条链表记录元素的存储顺序，保证元素有序
     * 有序的，也不允许重复元素
     */

    //不加泛型时默认什么都能存
    LinkedHashSet linkedHashSet = new LinkedHashSet();
    for (int i = 0;i&lt;5;i++)&#123;
        linkedHashSet.add(i);
    &#125;
    linkedHashSet.add(&quot;h&quot;);
    linkedHashSet.add(&quot;a&quot;);
    linkedHashSet.add(&quot;s&quot;);
    linkedHashSet.add(&quot;h&quot;);

    System.out.println();
    System.out.print(&quot;LinkedHashSet:&quot;);
    
    //Set集合的第二种遍历方式: 使用增强for循环遍历
    for (Object o:linkedHashSet)&#123;
        System.out.print(o +&quot; &quot;);  //0 1 2 3 4 h a s   顺序与输入时一致
    &#125;


&#125;

public static void map()&#123;
    /**
     * Map集合
     * Map&lt;K,V&gt;
     * 将键映射到值的对象，一个映射不能包含重复的键，每个键最多只能映射一个值
     *
     * 1. Map集合是一个双列集合，一个元素包含两个值(一个是key,一个是value)
     * 2. Map集合中的元素,key和value的数据类型可以相同,也可以不同
     * 3. Map集合中的元素,key不允许重复,value是可以重复的
     * 4. Map集合中的元素,key和value是一一对应的
     *
     * 常用方法
     * put(K key,V value): 把指定的键与指定的值添加到Map集合中
     *                      返回值：V
     *                      存储键值对时，key不重复，返回值V是null。key重复，会使用新的value替换map中重复的value，返回被替换的value值
     * remove(Object key): 把指定的键 所对应的键值对元素 在Map集合中删除,返回被删除元素的值
     *
     * get(Object key): 根据指定的键,在Map集合中获取对应的值
     *                  返回值:
     *                  key存在,返回对应值,key不存在则返回null
     *
     *
     */

    /**
     * HashMap&lt;K,V&gt;集合: Map接口的常用实现类
     * HashMap集合底层是哈希表;查询速度特别快.
     * HashMap集合是一个无序的集合,存储元素和取出元素的顺序可能不一致
     *
     */

    Map&lt;String,Integer&gt; hashMap = new HashMap&lt;&gt;();

    hashMap.put(&quot;武力&quot;,36);
    hashMap.put(&quot;智力&quot;,91);
    hashMap.put(&quot;统率&quot;,87);
    hashMap.put(&quot;政治&quot;,93);
    hashMap.put(&quot;魅力&quot;,99);

    //遍历方式一:hashMap.keySet() 把Map集合中所有的key取出来存储在Set集合中
    //          -&gt; 使用迭代器/增强for遍历set集合获取每一个key -&gt; get(key)获取键值
    Set&lt;String&gt; ability = hashMap.keySet();

    System.out.println();
    System.out.print(&quot;hashMap第一种遍历: &quot;);
    for (String key : ability) &#123;
        System.out.print(key+&quot;:&quot;+hashMap.get(key)+&quot; &quot;);  //hashMap第一种遍历: 政治:93 魅力:99 统率:87 武力:36 智力:91    无序的
    &#125;

    hashMap.remove(&quot;魅力&quot;);
    hashMap.put(&quot;武力&quot;,60);

    //遍历方式二:Entry键值对对象：Map.Entry&lt;K,V&gt;
    //在Map接口中有一个内部接口Entry
    //作用：当Map集合一创建，那么就会在Map集合中创建一个Entry对象，用来记录键与值(键值对对象,键与值的映射关系)
    //entrySet(): 把Map集合内部的多个entry对象取出来存储到一个Set集合中 -&gt; 遍历Set集合中的每一个Entry对象
    //Entry对象中的两个方法:getKey()获取所有key,getValue()获取所有value

    Set&lt;Map.Entry&lt;String, Integer&gt;&gt; entries = hashMap.entrySet();

    System.out.println();
    System.out.print(&quot;hashMap第二种遍历: &quot;);
    for (Map.Entry&lt;String, Integer&gt; entry : entries) &#123;
        System.out.print(entry.getKey()+&quot;:&quot;+entry.getValue()+&quot; &quot;);  //hashMap第二种遍历: 政治:93 统率:87 武力:60 智力:91   无序的
    &#125;


    /**
     * LinkedHashMap&lt;K,V&gt;
     * extends HashMap&lt;K,V&gt;
     * 有序的,存储abc,打印abc
     */
    LinkedHashMap&lt;String,String&gt; linked = new LinkedHashMap&lt;&gt;();
    linked.put(&quot;a&quot;,&quot;A&quot;);
    linked.put(&quot;c&quot;,&quot;C&quot;);
    linked.put(&quot;b&quot;,&quot;B&quot;);
    System.out.println();
    System.out.println(linked);   //&#123;a=A, c=C, b=B&#125;,key不允许重复,    有序的


    /**
     * HashTable&lt;K,V&gt;
     * HashMap:底层是一个哈希表,是一个线程不安全的集合,多线程,速度快
     * Hashtable:底层也是一个哈希表,是一个线程安全的集合,是单线程集合,速度慢
     *
     * HashMap集合(之前学的所有集合):可以存储null值,null键
     * Hashtable集合,不能存储null值,null键
     *
     * Hashtable和vector集合一样,在jdk1.2版本之后被更先进的集合(HashMap,ArrayList)取代了
     * Hashtable的子类Properties依然活跃在历史舞台
     * Properties集合是一个唯一和IO流相结合的集合
     */

    Hashtable properties = new Properties();
    properties.put(&quot;用户名&quot;,&quot;letter&quot;);
    properties.put(&quot;密码&quot;,&quot;letter&quot;);

    System.out.println();
    System.out.println(properties);  //&#123;用户名=letter, 密码=letter&#125;
&#125;

public static void transfer()&#123;
    //数组变字符串 连带数组的[]和,全转了
    String[] strings = &#123;&quot;h&quot;,&quot;e&quot;,&quot;l&quot;,&quot;l&quot;,&quot;o&quot;&#125;;

    String str = Arrays.toString(strings); //就长这样的字符串 [h, e, l, l, o]

    System.out.println(&quot;数组转换成字符串,strings:&quot;+strings+&quot; str:&quot;+str);
    //数组转换成字符串,strings:[Ljava.lang.String;@4554617c str:[h, e, l, l, o]

    //想变成hello  str不会改变而是再创,因此消耗内存,用StringBuilder
    String str2 = &quot;&quot;;
    for (String string : strings) &#123;
        str2 += string;
    &#125;
    System.out.println(&quot;直接String拼接:&quot;+str2);     //直接String拼接:hello

    /**
     * String类是常量，创建之后不可改变。进行字符串相加，内存中就会有多个字符串，占用空间多，效率低下
     * StingBuilder类 字符串缓冲区，可以提高字符串的操作效率底层是一个数组，但没有被final修饰，可以改变长度
     * StringBuilder在内存中始终是一个数组，占用空间少，效率高。初始长度16，如果超出容量，会自动扩容
     *
     * 拼接: .append()
     * 获取： .charAt()
     * 转为字符串: .toString()
     */
    StringBuilder str3 = new StringBuilder();
    for (String string : strings) &#123;
        str3.append(string);
    &#125;
    System.out.println(&quot;StringBuilder实现:&quot; + str3);  //StringBuilder实现:hello


    //字符串变数组
    char[] strings2 = str3.toString().toCharArray();
    for (char c : strings2) &#123;
        System.out.print(c+&quot;-&quot;);           // h-e-l-l-o-
    &#125;

    System.out.println();
    //集合变数组
    List&lt;String&gt; list = new ArrayList&lt;&gt;();
    list.add(&quot;a&quot;);
    list.add(&quot;b&quot;);
    list.add(&quot;c&quot;);

    Object[] listToArray = list.toArray();

    System.out.print(&quot;集合变数组:&quot;);
    for (Object o : listToArray) &#123;
        System.out.print(o);                //集合变数组:abc
    &#125;

&#125;
</code></pre>
<p>}</p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/shiqing/about" rel="external nofollow noreferrer">ShiQing</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://shiqing.gitee.io/shiqing/2020/10/26/java-ji-chu/datatype/">https://shiqing.gitee.io/shiqing/2020/10/26/java-ji-chu/datatype/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/shiqing/about" target="_blank">ShiQing</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/shiqing/tags/Java%E5%9F%BA%E7%A1%80/">
                                    <span class="chip bg-color">Java基础</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/shiqing/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/shiqing/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/shiqing/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/shiqing/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/shiqing/2020/11/12/cao-zuo-xi-tong/ji-suan-ji-wang-luo-fu-xi/">
                    <div class="card-image">
                        
                        
                        <img src="/shiqing/medias/featureimages/12.jpg" class="responsive-img" alt="&#39;计算机网络复习&#39;">
                        
                        <span class="card-title">&#39;计算机网络复习&#39;</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            计算机网络之基础篇一、计算机网络概述二、物理层三、数据链路层四、网络层五、传输层六、应用层
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-11-12
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/shiqing/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" class="post-category">
                                    计算机网络
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/shiqing/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/">
                        <span class="chip bg-color">计算机基础</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/shiqing/2020/07/08/java-kuang-jia/javanote-ssm/">
                    <div class="card-image">
                        
                        
                        <img src="/shiqing/medias/featureimages/10.jpg" class="responsive-img" alt="&#39;JavaNote_SpringMVC_Day03&#39;">
                        
                        <span class="card-title">&#39;JavaNote_SpringMVC_Day03&#39;</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Day3 SSM三大框架整合第一步：搭建整合环境SSM整合可以使用多种方式，我们选用XML+注解的方式
整合思路：    1. 搭建环境    2. 搭建Spring配置    3. 使用Spring整合SpringMVC框架    4. 
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-07-08
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/shiqing/categories/Java/" class="post-category">
                                    Java
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/shiqing/tags/Java%E6%A1%86%E6%9E%B6/">
                        <span class="chip bg-color">Java框架</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/shiqing/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/shiqing/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/shiqing/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/shiqing/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/shiqing/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




        <footer class="page-footer bg-color">
    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2024</span>
            
            <span id="year">2019</span>
            <a href="/shiqing/about" target="_blank">ShiQing</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/blinkfox" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:2528393970@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2528393970" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 2528393970" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/shiqing/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


        <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/shiqing/search.xml', 'searchInput', 'searchResult');
});
</script>

        <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


        <script src="/shiqing/libs/materialize/materialize.min.js"></script>
        <script src="/shiqing/libs/masonry/masonry.pkgd.min.js"></script>
        <script src="/shiqing/libs/aos/aos.js"></script>
        <script src="/shiqing/libs/scrollprogress/scrollProgress.min.js"></script>
        <script src="/shiqing/libs/lightGallery/js/lightgallery-all.min.js"></script>
        <script src="/shiqing/js/matery.js"></script>

        <!-- Baidu Analytics -->

        <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

        
        <script src="/shiqing/libs/others/clicklove.js" async="async"></script>
        
        
        <script async src="/shiqing/libs/others/busuanzi.pure.mini.js"></script>
        

        <script type="text/javascript">
            var OriginTitile = document.title,
                st;
            document.addEventListener("visibilitychange", function () {
                document.hidden ? (document.title = "看不见我~看不见我~", clearTimeout(st)) : (document.title =
                    "(๑•̀ㅂ•́) ✧被发现了～", st = setTimeout(function () {
                        document.title = OriginTitile
                    }, 3e3))
            })
        </script>

        <!-- 背景樱花飘落特效 -->
        
            <script type="text/javascript">
                //只在桌面版网页启用特效
                var windowWidth = $(window).width();
                if (windowWidth > 768) {
                    document.write('<script type="text/javascript" src="/js/xuehuapiaoluo.js"><\/script>');
                }
            </script>
        

        

        


        
        

        

        

        
        <script src="/shiqing/libs/instantpage/instantpage.js" type="module"></script>
        

    </body>

</html>
